﻿<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" version="1.0">

	<xsl:template match="jEditor">
		<div id="jEditor_toolbarSet">
			<xsl:apply-templates select="toolbarset" />
		</div>

		<div id="jEditor_editControlSet">
			<xsl:apply-templates select="editcontrol" />
		</div>

		<div id="jEditor_statusBar">
			<xsl:apply-templates select="statusbar" />
		</div>
		
		<xsl:apply-templates select="contextmenu" />

		<xsl:apply-templates select="propertypanel" />

		<xsl:apply-templates select="shortcutlist" />
		
	</xsl:template>

	<xsl:template match="toolbarset">
		<xsl:apply-templates select="toolbar" />
	</xsl:template>

	<xsl:template match="toolbar">
		<table class="toolbar" cellpadding="0" cellspacing="0">
			<xsl:attribute name="id">jEditor_toolbar_<xsl:value-of select="@id" /></xsl:attribute>
			<tr><td>				
				<span class="handle"><xsl:attribute name="style">background-image:url(<xsl:value-of select="/jEditor/@baseurl" />images/bg_handle.gif)</xsl:attribute></span>
			</td>
			<td nowrap="true">				
				<xsl:attribute name="enable"><xsl:value-of select="@enable" /></xsl:attribute>
				<xsl:apply-templates select="button|separator|checkbutton|menubutton|listbutton|html" />
			</td></tr>
		</table>
	</xsl:template>

	<xsl:template match="statusbar">
		<table>
			<tr><td nowrap="true">				
				<xsl:attribute name="enable"><xsl:value-of select="@enable" /></xsl:attribute>
				<xsl:apply-templates select="button|separator|checkbutton|menubutton|listbutton" />
			</td></tr>
		</table>
	</xsl:template>

	<xsl:template match="html">
		<span style="font-size:12px;height:16px;">
			<xsl:value-of/>
			<!-- <xsl:for-each select="input">
				<input style="background-color:transparent;">
					<xsl:for-each select="@*">
						<xsl:attribute><xsl:value-of/></xsl:attribute>
					</xsl:for-each>
					<xsl:value-of/>
				</input>
			</xsl:for-each> -->
		</span>
	</xsl:template>

	<xsl:template match="button">
		<span class="button" type="button">
			<xsl:attribute name="onmouseover">this.className='button_hover'</xsl:attribute>
			<xsl:attribute name="onmouseout">this.className='button'</xsl:attribute>
			<xsl:attribute name="onclick">with(<xsl:value-of select="/jEditor/@uniqueID" />){try{if(eval(this.enable)){eval(this.cmd);displayChanged();}}catch(error){};editControl.DOM.focus();}</xsl:attribute>
			<xsl:attribute name="cmd"><xsl:value-of select="@cmd" /></xsl:attribute>
			<xsl:attribute name="enable"><xsl:value-of select="@enable" /></xsl:attribute>
			<xsl:attribute name="baseurl"><xsl:value-of select="/jEditor/@baseurl" /></xsl:attribute>
			<img height="16">
				<xsl:attribute name="src"><xsl:value-of select="/jEditor/@baseurl" /><xsl:value-of select="@image" /></xsl:attribute>
				<xsl:attribute name="title"><xsl:value-of select="@label" /></xsl:attribute>
			</img>
		</span>
	</xsl:template>

	<xsl:template match="listbutton">
		<select>
			<xsl:attribute name="ancestor"><xsl:value-of select="/jEditor/@uniqueID" /></xsl:attribute>
			<xsl:attribute name="editable"><xsl:value-of select="@editable" /></xsl:attribute>
			<xsl:attribute name="style">width:<xsl:value-of select="@width" />;behavior:url(<xsl:value-of select="/jEditor/@baseurl" />jeditor_editable_select.htc);</xsl:attribute>
			<xsl:attribute name="cmd"><xsl:value-of select="@cmd" /></xsl:attribute>
			<xsl:attribute name="enable"><xsl:value-of select="@enable" /></xsl:attribute>				
			<xsl:attribute name="default"><xsl:value-of select="@default" /></xsl:attribute>
			<xsl:apply-templates select="listitem" />
		</select>
	</xsl:template>

	<xsl:template match="listitem">
		<option>
			<xsl:attribute name="value"><xsl:value-of select="@value" /></xsl:attribute>
			<xsl:value-of select="@label" />
		</option>
	</xsl:template>

	<xsl:template match="menubutton">
		<span class="button" type="menubutton" style="position:relative;z-index:1000">
			<xsl:attribute name="cmd"><xsl:value-of select="@cmd" /></xsl:attribute>
			<xsl:attribute name="enable"><xsl:value-of select="@enable" /></xsl:attribute>
			<xsl:attribute name="baseurl"><xsl:value-of select="/jEditor/@baseurl" /></xsl:attribute>

			<xsl:attribute name="onmouseover">this.className='button_hover'</xsl:attribute>
			<xsl:attribute name="onmouseout">this.className='button'</xsl:attribute>
			<xsl:attribute name="onclick">with(<xsl:value-of select="/jEditor/@uniqueID" />){try{if(eval(this.enable)){eval(this.cmd);displayChanged();}}catch(error){};}</xsl:attribute>
			<img>
				<xsl:attribute name="src"><xsl:value-of select="/jEditor/@baseurl" /><xsl:value-of select="@image" /></xsl:attribute>
				<xsl:attribute name="title"><xsl:value-of select="@label" /></xsl:attribute>
			</img>
			<xsl:apply-templates select="menuitem" />
		</span>
	</xsl:template>

	<xsl:template match="menuitem">
		<span style="position:relative"><object type="text/x-scriptlet">
			<xsl:attribute name="ancestor"><xsl:value-of select="/jEditor/@uniqueID" /></xsl:attribute>
			<xsl:attribute name="data"><xsl:value-of select="/jEditor/@baseurl" /><xsl:value-of select="@data" /></xsl:attribute>
			<xsl:attribute name="id"><xsl:value-of select="@id" /></xsl:attribute>
			<xsl:attribute name="class">menu<xsl:value-of select="../@direction" /></xsl:attribute>
			<br />
		</object></span>
	</xsl:template>


	<xsl:template match="checkbutton">
		<span class="button" type="checkbutton">
			<xsl:attribute name="onmouseover">if(this.className!='button_checked'){this.className='button_hover'}</xsl:attribute>
			<xsl:attribute name="onmouseout">if(this.className!='button_checked'){this.className='button'}</xsl:attribute>
			<xsl:attribute name="onclick">with(<xsl:value-of select="/jEditor/@uniqueID" />){try{if(eval(this.enable)){eval(this.cmd);displayChanged();}}catch(error){}}</xsl:attribute>
			<xsl:attribute name="cmd"><xsl:value-of select="@cmd" /></xsl:attribute>
			<xsl:attribute name="enable"><xsl:value-of select="@enable" /></xsl:attribute>
			<xsl:attribute name="baseurl"><xsl:value-of select="/jEditor/@baseurl" /></xsl:attribute>
			<xsl:attribute name="checked"><xsl:value-of select="@checked" /></xsl:attribute>
			<img>
				<xsl:attribute name="src"><xsl:value-of select="/jEditor/@baseurl" /><xsl:value-of select="@image" /></xsl:attribute>
				<xsl:attribute name="title"><xsl:value-of select="@label" /></xsl:attribute>
			</img>
		</span>
	</xsl:template>

	<xsl:template match="separator">
		<span class="separator"></span>
	</xsl:template>

	<xsl:template match="editcontrol">
		<object id="jEditor_editControl" CLASSID="clsid:2D360201-FFF5-11D1-8D03-00A0C959BC0A">
			<param name="UseDivOnCarriageReturn" VALUE="1"/>
		</object>
		<textarea id="jEditor_editControl_code"></textarea>
	</xsl:template>

	<xsl:template match="contextmenu">
		<span id="jEditor_contextmenu" class="contextmenu">
			<object type="text/x-scriptlet" style="width:100%;height:100%">
				<xsl:attribute name="data"><xsl:value-of select="/jEditor/@baseurl" /><xsl:value-of select="@data" /></xsl:attribute>
				<br />
			</object>
			<xsl:apply-templates select="contextitem|separator" />
		</span>
	</xsl:template>

	<xsl:template match="contextitem">
		<contextitem>
			<xsl:attribute name="id"><xsl:value-of select="@id" /></xsl:attribute>
			<xsl:attribute name="value"><xsl:value-of select="@label" /></xsl:attribute>
			<xsl:attribute name="cmd"><xsl:value-of select="@cmd" /></xsl:attribute>
			<xsl:attribute name="handle"><xsl:value-of select="@handle" /></xsl:attribute>
			<xsl:attribute name="image"><xsl:value-of select="@image" /></xsl:attribute>
			<xsl:attribute name="type"><xsl:value-of select="@type" /></xsl:attribute>
			<xsl:attribute name="checked"><xsl:value-of select="@checked" /></xsl:attribute>
			<xsl:attribute name="enable"><xsl:value-of select="@enable" /></xsl:attribute>
		</contextitem>
	</xsl:template>

	<xsl:template match="contextmenu/separator">
		<contextitem id="" value="" cmd="" image="" type="separator" checked="">
			<xsl:attribute name="handle"><xsl:value-of select="@handle" /></xsl:attribute>
			<xsl:attribute name="enable"><xsl:value-of select="@enable" /></xsl:attribute>
		</contextitem>
	</xsl:template>


	<xsl:template match="propertypanel">
		<object type="text/x-scriptlet" class="panel" id="jEditor_propertyPanel">
			<xsl:attribute name="data"><xsl:value-of select="/jEditor/@baseurl" /><xsl:value-of select="@data" /></xsl:attribute>		
		<br/>
		</object>
	</xsl:template>


	<xsl:template match="shortcutlist">
		<div id="jEditor_shortcutList">
			<xsl:apply-templates select="shortcut" />
		</div>
	</xsl:template>


	<xsl:template match="shortcut">
		<shortcut>
			<xsl:attribute name="key"><xsl:value-of select="@key" /></xsl:attribute>
			<xsl:attribute name="cmd"><xsl:value-of select="@cmd" /></xsl:attribute>
			<xsl:attribute name="enable"><xsl:value-of select="@enable" /></xsl:attribute>
			<xsl:attribute name="cancel"><xsl:value-of select="@cancel" /></xsl:attribute>
		</shortcut>
	</xsl:template>
	
</xsl:stylesheet>